//统计界面的js
var $dataTable;
function deleteProject(id) {
	if (id == null) {
		alert('id为空');
	}
	if (confirm('确定删除该项目吗?')) {
		var param = {};
		param.id = id;
		postContent("/project/delete", param, true, function(data) {
			if (data != null) {
				alert('删除成功!');
				$dataTable.ajax.reload();
			}
		});
	}
}

function modiProject(id) {
	if (id == null) {
		alert('id为空');
	}
	var param = {};
	param.id = id;
	showContent('/view/project-create.html',param,createInit);
}


function allProjectInit() {
	$dataTable = $('#option')
			.DataTable(
					getCommonPageParam(
							"/project/showPage",
							{},
							true,
							[ {
								"mData" : "shortName"
							}, {
								"mData" : "manager"
							}, {
								"mData" : "totalCollect"
							}, {
								"mData" : "establishdate"
							}, {
								"mData" : "exchangeName"
							}, {
								"mData" : "sublist"
							}, {
								"mData" : "subcreate"
							}, {
								"mData" : "generate"
							}, {
								"mData" : "operation"
							} ],
							function(resp) {
								var data = resp.aaData;
								for (num in data) {
									var id = data[num].id;
									var establishStr = "";
									data[num].shortName = '<a href="#" onclick=modiProject('
											+ id
											+ ')>'
											+ data[num].shortName
											+ '</a>';
									if(data[num].expiredate!=null){
										data[num].expiredate = (new Date(data[num].expiredate.time)).Format("MM/dd/yyyy");
									}
									if(data[num].begindate!=null){
										data[num].begindate = (new Date(data[num].begindate.time)).Format("MM/dd/yyyy");
									}
									if(data[num].establishdate!=null){
										establishStr = (new Date(data[num].establishdate.time)).Format("MM/dd/yyyy")
										data[num].establishdate = establishStr;
									}
									data[num].sublist = '<a href="#" onclick=showSubProject('+id+')>查看子项目列表</a>';
									data[num].subcreate = '<a href="#" onclick=createSubProject("'+id+'","'+establishStr+'")>创建子项目</a>';
									data[num].operation = '<a href="#" onclick=deleteProject('
											+ id + ')>删除</a>';
									data[num].generate = '<a href="#" onclick=showTemplateGenerate('+id+',0)>生成</a>';
								}
								return resp;
							}));
}